﻿using System;
using System.Runtime.Serialization;

namespace SharedObjects
{
	[DataContract]
	[KnownType(typeof(Agent))]
	[KnownType(typeof(Account))]
	[KnownType(typeof(Credential))]
	[KnownType(typeof(Bypasser))]
	[KnownType(typeof(ClientConfiguration))]
	[KnownType(typeof(ComputerSystem))]
	[KnownType(typeof(ComputerSystemAccount))]
	[KnownType(typeof(ComputerSystemFeature))]
	[KnownType(typeof(ReadableComputerSystemLog))]
	[KnownType(typeof(Corporation))]
	[KnownType(typeof(Tld))]

	[KnownType(typeof(Cpu))]
	[KnownType(typeof(Credential))]
	[KnownType(typeof(CredentialFile))]
	[KnownType(typeof(DnaCredential))]
	[KnownType(typeof(FingerprintCredential))]
	[KnownType(typeof(RetinalScanCredential))]
	[KnownType(typeof(UsernamePasswordCredential))]
	[KnownType(typeof(ErrorLog))]
	[KnownType(typeof(Fragment))]
	[KnownType(typeof(Gateway))]
	[KnownType(typeof(GatewayBlueprint))]
	[KnownType(typeof(MemoryType))]
	[KnownType(typeof(NetworkAddress))]
	[KnownType(typeof(NetworkAdapter))]
	[KnownType(typeof(Program))]				//**
	[KnownType(typeof(ProgramCategory))]		//**
	[KnownType(typeof(ProgramFile))]			//**
	[KnownType(typeof(SavedConnection))]		//**
	[KnownType(typeof(SecuritySystem))]			//**
	[KnownType(typeof(SystemDirectory))]		//**
	[KnownType(typeof(SystemFile))]				//**
	[KnownType(typeof(UserProgram))]			//**
	[KnownType(typeof(UserProgramFragment))]	//**
	[KnownType(typeof(WorldData))]

	[KnownType(typeof(EmailAccount))]
	[KnownType(typeof(EmailBody))]
	[KnownType(typeof(EmailHeader))]
	[KnownType(typeof(ShortEmailAccountInfo))]

	[KnownType(typeof(BankAccount))]
	[KnownType(typeof(BankTransaction))]

	[KnownType(typeof(StoryArc))]
	[KnownType(typeof(StoryTask))]
	[KnownType(typeof(StoryTaskObjective))]
	public class EntityBase
	{
		[DataMember] public ulong Id { get; set; }
		public bool IsDeleted { get; set; }
		public DateTime DeletionTimeStamp { get; set; }
	}

	public enum Entities
	{
		Agent,
		Account,
		Credential,
		Bypasser,
		ClientConfiguration,
		ComputerSystem,
		ComputerSystemAccount,
		ComputerSystemFeature,
		ComputerSystemLog,
		Corporation,
		Cpu,
		ErrorLog,
		Fragment,
		Gateway,
		GatewayBlueprint,
		GatewayMemoryMap,
		MemoryType,
		NetworkAddress,
		Program,
		ProgramCategory,
		ProgramFile,
		SavedConnection,
		SecuritySystem,
		SystemDirectory,
		SystemFile,
		UserProgram,
		UserProgramFragment,
		WorldData,
	}

	[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
	public class ReferencedByAttribute : Attribute
	{
		public Type ByType;
		public ReferencedByAttribute(Type byType)
		{
			ByType = byType;
		}
	}

	public enum RequiredType
	{
		AtLeastOne,
		ExactlyOne
	}

	[AttributeUsage(AttributeTargets.Property)]
	public class RequiredAttribute : Attribute
	{
		public RequiredType Type { get; set; }

		/// <summary>
		/// Default RequiredType is ExactlyOne.
		/// </summary>
		public RequiredAttribute()
		{
			Type = RequiredType.ExactlyOne;
		}

		public RequiredAttribute(RequiredType type)
		{
			Type = type;
		}
	}

	[AttributeUsage(AttributeTargets.Property)]
	public class DeleteCascadeAttribute : Attribute
	{
		
	}
}
